<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>退货订单列表</h2>
	</div>
	<div class="cf">
		<div class="search-form fr cf">
			<if condition="IS_ADMIN">
				<div class="btn-group-click adv-sch-pannel fl">
					<label>分类：</label>
					 <!-- onchange="changeOrder(this);" -->
		    		<select name="class_id" id="class_id" onchange="changeOrder(this);">
		    			<option value="order|-1">--请选择--</option>
		    			<volist name="classes" id="v">
		    				<option value="{$v.id}" <if condition="I('class_id') eq $v['id']">selected="selected"</if>>{$v.name}</option>
		    			</volist>
		    		</select>
				</div>
			</if>
			<div class="sleft">
				<input type="text" id="time-start" name="time-start" class="search-input" value="{:I('time-start')}" placeholder="查询开始时间" />
				<input type="text" id="time-end" name="time-end" class="search-input" placeholder="结束时间" value="{:I('time-end')}" />
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('Finance/index')}"><i class="btn-search"></i></a>
			</div>
		</div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="pay_order">
    <thead>
        <tr>
		<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
		<th class="">序号</th>
		<th class="">订单号</th>
		<th class="">退款时间</th>
		<th class="">退款金额</th>
		<th class="">银行手续费</th>
		<th class="">定制价</th>
		<th class="">退款总金额</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
			<td>{$key + 1} </td>
			<td>{$vo.order_id}</td>
			<td>
				<if condition="$vo.return_stime gt 0">
					{$vo.return_stime|date="Y-m-d H:i", ###}
				<else />
					0
				</if>
			</td>
			<td rmoney="{$vo.return_money}">￥{$vo.return_money}</td>
			<td bank="{$vo.bank}">￥{$vo.bank}</td>
			<td zkj="{$vo.zkj}">￥{$vo.zkj}</td>
			<td profit="{$vo.allMoney}">￥{$vo.allMoney}</td>
		</tr>
		</volist>
		<tr>
            <td colspan=''></td>
			<td>总计</td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td>￥</td>
		</tr>
		<else/>
		<td colspan="8" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
	<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
	<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
	<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
	<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
	<script type="text/javascript">

	$(function(){
		var obj = $('.pay_order tbody tr');
		var tr_count = obj.length - 2;
		var all_price = 0,
			rmoney = 0,
			bank = 0,
			zkj = 0;
		for (var i = 0; i <= tr_count; i ++) {
			rmoney += parseFloat(obj.eq(i).find('td').eq(4).attr('rmoney'));
			bank += parseFloat(obj.eq(i).find('td').eq(5).attr('bank'));
			zkj += parseFloat(obj.eq(i).find('td').eq(6).attr('zkj'));
			all_price += parseFloat(obj.eq(i).find('td:last').attr('profit'));
		};
		$('.pay_order>tbody>tr:last').find('td').eq(4).html( '￥' + rmoney.toFixed(2) );
		$('.pay_order>tbody>tr:last').find('td').eq(5).html( '￥' + bank.toFixed(2) );
		$('.pay_order>tbody>tr:last').find('td').eq(6).html( '￥' + zkj.toFixed(2) );
		$('.pay_order>tbody>tr:last').find('td:last').html( '￥' + all_price.toFixed(2) );
	});

	//搜索功能
	$("#search").click(function(){
		var url = window.location.href;
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});

	$('#time-start').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });

    $('#time-end').datetimepicker({
       format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true,
        pickerPosition:'bottom-left'
    });

    function changeOrder(obj){
		var url = "{:U('index')}";
		if( url.indexOf('?')>0 ){
			url += '&class_id=' + obj.value;
		}else{
			url += '?class_id=' + obj.value;
		}
		window.location.href = url;
	}
	
    //导航高亮
    highlight_subnav('{:U('ReturnOrder/index')}');
	</script>
</block>
